import java.util.*;

public class StudentTest {
    public static void main(String[] args) {
        Map<Student, String> map = new HashMap<>();
        map.put(new Student("张三",18),"海淀区");
        map.put(new Student("李四",19),"朝阳区");
        map.put(new Student("王五",17),"昌平区");
        map.put(new Student("孔六",20),"西城区");
        System.out.println("-----------------1:keySet-----------------");
        Set<Student> set = map.keySet();
        for(Student stu : set){
            System.out.println("<age:"+stu.getAge() + ", name:"+stu.getName() +">::"+ map.get(stu));
        }

        System.out.println("-----------------2:foreach-----------------");
        for(Map.Entry<Student,String> entry: map.entrySet()){
            System.out.println("<age:"+entry.getKey().getAge() + ", name:"+entry.getKey().getName() +">::"+ entry.getValue());
        }

        System.out.println("-----------------3:迭代器-----------------");
        Iterator<Student> it = map.keySet().iterator();
        while(it.hasNext()){
            Student stu = it.next();
            System.out.println("<age:"+stu.getAge() + ", name:"+stu.getName() +">::"+ map.get(stu));

        }
        System.out.println("-----------------4:lambda-----------------");
        map.forEach((key,value)->{
            System.out.println("<age:"+key.getAge() + ", name:"+key.getName() +">::"+ value);
        });
    }
}
